<?php

namespace App\Http\Controllers\Asset;

use App\Contracts\ErrorCode;
use App\Http\Controllers\Controller;
use App\Models\AssetBrand;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request;

class AssetBrandController extends Controller
{
    public function store(Request $request)
    {
        try {
            $result = AssetBrand::create($request->only(['name']));
            return response()->json(compact(['result']));
        } catch (QueryException $e) {
            return response()->json([
                "error" => ErrorCode::$DUPLICATED_ENTITY_ERROR,
                "message" => "品牌名称已经存在"
            ]);
        }
    }
}
